import 'dart:math';

import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';

class UtilsComment {
  // static getDistance(BMFCoordinate startCoord, BMFCoordinate endCoord) {
  //   /// 单位：米
  //   double def = 6378137.0;
  //   double radLat1 = _rad(startCoord.latitude);
  //   double radLat2 = _rad(endCoord.latitude);
  //   double a = radLat1 - radLat2;
  //   double b = _rad(startCoord.longitude) - _rad(startCoord.longitude);
  //   double s = 2 *
  //       asin(sqrt(pow(sin(a / 2), 2) +
  //           cos(radLat1) * cos(radLat2) * pow(sin(b / 2), 2)));
  //   return (s * def).roundToDouble();
  // }

  static double _rad(double d) {
    return d * pi / 180.0;
  }

  /// 校验密码格式 8-16个字符,不包含空格,必须包含数字,字母或字符至少两种
  static bool checkPasswordFormal(String value) {
    //最接近的
    //String regex = "^(?!^(\\d+|[a-zA-Z]+|[~!@#$%^&*?/]+)$)^[\\w~!@#$%^&*?/]{8,16}$";
    //纯字符不行
    //String regex = "(?!.*\\s)(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^[^\\s\\u4e00-\\u9fa5]{8,16}";
    //中文 和 纯字符 不行
    //String regex = "(?!.*\\s)(?!^[\\u4e00-\\u9fa5]+$)(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{8,16}$";
    String regex =
        "^(?=.*\\d)(?!^[0-9]+\$)(?!^[A-z]+\$)(?!^[^A-z0-9]+\$)^[^\\s\\u4e00-\\u9fa5]{8,16}";
    return RegexUtil.matches(regex, value);
    // return value.matches(regex);
  }

  static List gameCommentUserColors() {
    return [
      [Color(0xff68DF95), Color(0xff36C2B3)],
      [Color(0xffFFDE37), Color(0xffFFA632)],
      [Color(0xff75DCFF), Color(0xff5369C2)],
      [Color(0xffFF804A), Color(0xffEC4364)],
    ];
  }

  static List randomColor() {
    List list = gameCommentUserColors();
    int index = Random().nextInt(list.length - 1);
    return list[index];
    // return gameCommentUserColors();
    // return Color.fromARGB(255, Random().nextInt(256) + 0,
    // Random().nextInt(256) + 0, Random().nextInt(256) + 0);
  }
}
